<template>
  <div>
    <nav class="navbar nav-dark bg-primary justify-content-betewwn mb-4 px-4">
      <RouterLink to="/" class="navbar-brand">专栏</RouterLink>
      <ul v-if="!user.isLogin" class="list-inline mb-0">
        <li class="list-inline-item">
          <RouterLink to="/login" class="btn btn-outline-light my-2"
            >登录</RouterLink
          >
        </li>
        <li class="list-inline-item">
          <RouterLink to="/signup" class="btn btn-outline-light my-2">注册</RouterLink>
        </li>
      </ul>
      <ul v-else class="list-inline mb-0">
        <DropDown :title="`你好${user.nickName}`">
          <DropDownItem>
            <RouterLink to="/create" class="dropdown-item">新建文章</RouterLink>
          </DropDownItem>
          <DropDownItem>
            <RouterLink to="" class="dropdown-item">修改资料</RouterLink>
          </DropDownItem>
          <DropDownItem>
            <RouterLink to="" class="dropdown-item">退出登录</RouterLink>
          </DropDownItem>
        </DropDown>
      </ul>
    </nav>
  </div>
</template>

<script lang="ts">
import { PropType, defineComponent } from "vue";
import DropDown from "./DropDown.vue";
import DropDownItem from "./DropDownItem.vue";
import { RouterLink } from "vue-router";
import {UserProps} from "@/store";
// export interface UserProps {
//   isLogin: boolean;
//   nickName?: string;
//   id?: number;
// }
export default defineComponent({
  name: "GlobalHeader",
  props: {
    user: {
      type: Object as PropType<UserProps>,
      required: true,
    },
  },
  components: {
    DropDown,
    DropDownItem,
    RouterLink,
  },
  setup() {
    return {};
  },
});
</script>

<style scoped></style>
